<?php

namespace app\web\controller;
use app\web\model\PaylogModel;
use app\common\controller\StoreBaseController;
use think\Db;
/**
 * 交易记录
 */
class PaylogController extends StoreBaseController
{
 	 protected $model;
	
    protected function _initialize() {
        parent::_initialize();
        $this->model = new PaylogModel();
    }
    /**
     * 交易记录列表
     * @author [lx] 
     */
    public function index( $page = 1){
        $list = $this->model->paginate(10);
        return $this->fetch('index', ['list' => $list]);
    }
    /**
     * [search查询]
     * @author [lx] 
     */
    public function search(){
    	$map = [];
    	$field = 'm.*,g.*';
		if(request()->isPost()){
			
		 	$param = input('post.');
	
			//用户类型
			if($param['user_type']!= 0){
				$map['user_type'] = ['like', '%'.$param['user_type'].'%'];
			}
			//操作类型
			if($param['type'] != 0){
				$map['type'] = ['like', '%'.$param['type'].'%'];
			}
			//支付类型
			if($param['pay_type']!= 0){
				$map['pay_type'] = ['like', '%'.$param['pay_type'].'%'];
			}
	    }	
    		$list=Db::name("mall_paylog")
    		->alias('m')
    		->join('__MEMBER__ g','g.id=m.uid')
    		->field($field)
    		->where($map)
    		->order("m.add_time desc")
    		->paginate(10);       

        return $this->fetch('index', ['list' => $list]);
    }
}